<?php
class Master_lembaga extends CI_Model 
{

	function __construct()
	{
		parent::__construct();
	}
	
	function add($dataInsert)
	{
		$query = $this->db->insert('mr_lembaga', $dataInsert);
		return $query;
	}
	
	function get_all(){
		$sql="select * from mr_lembaga order by id_lembaga asc";
		$query=$this->db->query($sql);
		if ($query->num_rows()>0){
			return $query->result_array();
		}else{
			return array();
		}
	}
	
	function read()
	{	
		$this->db->order_by('nama_lembaga');		
		$query=$this->db->get('mr_lembaga');
		return $query->result();
	}
	
	function edit($id_mr_lembaga)
	{
		$this->db->where('id_lembaga',$id_mr_lembaga);
		$query=$this->db->get('mr_lembaga');
		return $query->result();
	}
	
	function update($id_mr_lembaga,$dataUpdate)
	{
		$this->db->where('id_lembaga', $id_mr_lembaga);
		$update = $this->db->update('mr_lembaga', $dataUpdate);
		return $update;
	}
	
	function delete($id_mr_lembaga)
	{
		$this->db->where('id_lembaga', $id_mr_lembaga);
		$delete = $this->db->delete('mr_lembaga');
		return $delete;
	}

	function limit($limit,$offset)
	{	
		$this->db->order_by('nama_lembaga');		
		$query=$this->db->get('mr_lembaga',$limit,$offset);
		return $query->result();
	}

	function num_rows()
	{	
		$query = $this->db->get('mr_lembaga');
		return $query->num_rows();
	}
	
	function detail($id){
		$sql="select * from mr_lembaga where id_lembaga='".$id."'";
		$query=$this->db->query($sql);
		if ($query->num_rows()>0){
			return $query->row_array();
		}else{
			return array();
		}
	}

}